package com.cloudwise.io;

import com.cloudwise.entity.Student;

import java.io.*;

/**
 * @author ：Teacher陈
 * @date ：Created in 2020/12/29 11:44
 * @description：
 * @modified By：
 * @version:
 */
public class SerialisTest {
    public static void main(String[] args) throws Exception {
        /*Student  student= new Student();
        student.setId(100);
        student.setName("zhangsan");
        //持久化对象到文件中
        OutputStream outputStream= new FileOutputStream("D:\\stu.txt");
        ObjectOutputStream objectOutputStream= new ObjectOutputStream(outputStream);
        objectOutputStream.writeObject(student);
        objectOutputStream.flush();
        objectOutputStream.close();
        outputStream.close();*/

        //反序列化
       // File file= new File("D:\\stu.txt");
      /*  InputStream inputStream = new FileInputStream("D:\\stu.txt");
        ObjectInputStream objectInputStream= new ObjectInputStream(inputStream);
        Object o = objectInputStream.readObject();
        System.out.println(o.toString());*/
      File file = new File("f:\\xxx.txt");
      InputStreamReader inputStreamReader= new InputStreamReader(new FileInputStream(file));
     // FileReader fileReader = new FileReader(file);
      BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        String s = bufferedReader.readLine();
        System.out.println(s);
    }
}
